package com.ken.base_http_library.http_api_impl

import android.util.Log
import com.ken.base_http_library.callback.OnDesCallback
import io.reactivex.Observer
import io.reactivex.disposables.Disposable


/**
 * @author by ken
 * Blog:
 * Date:2020/5/7
 * Description:
 */
class Destiny<T> : Observer<T> {
    var callBack: OnDesCallback<T>? = null

    constructor(callBack: OnDesCallback<T>) {
        this.callBack = callBack
    }

    override fun onComplete() {
    }

    override fun onSubscribe(d: Disposable) {
    }

    override fun onNext(t: T) {
        callBack?.onSuccess(t)
    }

    override fun onError(e: Throwable) {
        Log.e(
            "medtap_http_error",
            "error_msg:" + e.message
                    + "\n"
                    + "error_cause:"
                    + e.cause
        )
        callBack?.onError(e)
    }
}